package heven.holt.library.initializer.startup

import android.content.Context
import com.tencent.smtt.export.external.TbsCoreSettings
import com.tencent.smtt.sdk.QbSdk
import heven.holt.library.startup.AndroidStartup
import timber.log.Timber

class TencentStartUp : AndroidStartup<Any>() {
    override fun create(context: Context): Any? {
        QbSdk.initX5Environment(context, object : QbSdk.PreInitCallback {
            override fun onCoreInitFinished() {
                Timber.d("initX5Environment onCoreInitFinished")
            }

            override fun onViewInitFinished(p0: Boolean) {
                Timber.d("initX5Environment onViewInitFinished ：$p0")
            }
        })
        QbSdk.initTbsSettings(
            mapOf(
                TbsCoreSettings.TBS_SETTINGS_USE_SPEEDY_CLASSLOADER to true,
                TbsCoreSettings.TBS_SETTINGS_USE_DEXLOADER_SERVICE to true
            )
        )
        return null
    }

    override fun callCreateOnMainThread(): Boolean = true

    override fun waitOnMainThread(): Boolean = false
}